@echo off
IF  "%1"=="1" GOTO :echoOn
GOTO :StartScript

:EchoOn
@Echo on
GOTO :StartScript

:StartScript
rem
REM Batch file to collect RM Log Files.
REM 
REM Date Created: 23/04/2010
REM Created By: Russell Dyas
REM Copyright 2010
REM
REM 
REM
REM Variables Used:
REM 
REM WorkingDir = This is the direcotry that the script has been ran from
REM WorkingDate = This is todays current date
REM WorkingTime = This is current time.
REM RMLOGDIR = This is name of the log store
REM CURRENTVERSION = This is current version of the getlogs script. 
REM Increase the current version vlaue when change the script. Increase Major Value when big changes to script
REM minor values when small edits .
REM
REM  PLEASE ALSO EDIT THE CHAnGES.TXT FILE
REM  
REM 
REM Clears Screen, Sets Variables & Displays Welcome Message.
cls
SET CURRENTVERSION=V1.2
Set WORKINGDIR=%CD%
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET WORKINGDATE=%date:~0,2%-%date:~3,2%-%date:~6,6%
set WorkingTime=%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%
SET RMLOGDIR=RMLOGS-%computername%-%WORKINGDATE%-%WorkingTime%
Echo RM Log File Getter %CURRENTVERSION%
Echo RM Log File Getter %CURRENTVERSION%>>%RMLOGDIR%.LOG
echo.
Echo Variables Currently Set As:
Echo.
Echo WorkingDir = %WorkingDir%>>%RMLOGDIR%.LOG
Echo WorkingDate = %WorkingDate%>>%RMLOGDIR%.LOG
Echo WorkingTime = %WorkingTime%>>%RMLOGDIR%.LOG
Echo RMLOGDIR = %RMLOGDIR%>>%RMLOGDIR%.LOG
IF  "%1"=="1" echo Currently Running In Debug Mode>>%RMLOGDIR%.LOG
ECHO.
PAUSE

MD %RMLOGDIR%

REM Gets The BootStrapper Logs.
copy "C:\Program Files\RM\Connect\RM Connect Bootstrapper\RM Bootstrapper Log.txt" %RMLOGDIR%>>%RMLOGDIR%.LOG

REM Gets The Build Client Logs.
xcopy "C:\Program Files\RM\Connect\Build\Build Client\Logs\*.*" %RMLOGDIR%\BuildClientLogs\*.* /S /E>>%RMLOGDIR%.LOG

REM Gets Logs Files To Do With Driver Installs.
xcopy "C:\DriverApply\Metadata\*.xml" %RMLOGDIR%\DriverApplyLogs\*.xml /s /E>>%RMLOGDIR%.LOG

REM Extracts Event Viewer Application and System & Then Moves Them To Log Store.
Echo Currently Exporting Event Viewer Application>>%RMLOGDIR%.LOG
wscript backupapp.vbs
Echo Currently Exporting Event Viewer System>>%RMLOGDIR%.LOG
wscript backupsys.vbs
Move *.evt %RMLOGDIR%>>%RMLOGDIR%.LOG

REM Gets Rm Comms Logs.
xcopy "C:\Program Files\RM\Connect\Comms\Diagnostics\*.*" %RMLOGDIR%\Comms\*.* /S /E>>%RMLOGDIR%.LOG

REM Gets Network Management Log Files.
xcopy "C:\Program Files\Research Machines\Network Management\LogFiles\*.*" "%RMLOGDIR%\Network Managment-LogFiles\*.*" /S /E>>%RMLOGDIR%.LOG

:JUMP

REM Zips the Log Store Into A Zip File.
7za a -tzip -r %RMLOGDIR%.zip %CD%\%RMLOGDIR%\*.*>>%RMLOGDIR%.LOG

echo.>>%RMLOGDIR%.LOG
echo.>>%RMLOGDIR%.LOG
Echo Logs Have Been Added To %RMLOGDIR%.zip.>>%RMLOGDIR%.LOG
echo.>>%RMLOGDIR%.LOG
Echo Now Completed.>>%RMLOGDIR%.LOG
Echo Now Completed.
pause